15. Train Your SVM
Train Your SVM
Once your feature extraction has successfully completed, you're ready to train your model. First, however, if you don't already have them, you'll need to install the sklearn
and scipy
Python packages. You can install these using pip
:
$ pip install sklearn scipy
After that, you're ready to run the train_svm.py
script to train an SVM classifier on your labeled set of features.
$ rosrun sensor_stick train_svm.py
When this runs you'll get some text output at the terminal regarding overall accuracy of your classifier and two plots will pop up showing the relative accuracy of your classifier for the various objects:
These plots are showing you two different versions of the confusion matrix for your classifier. On the left is raw counts and on the right as a percentage of the total. Given that during the feature generation process objects are spawned in random orientations, you plots most likely will look slightly different.
Running the above command will also result in your trained model being saved in a model.sav
file. Note: This model.sav
file will be saved in the catkin_ws
folder.
Confusion Matrix Intuitions
QUIZ QUESTION::
**Take a closer look at the confusion matrices shown above (you can click on the image to enlarge). Match the result statements below with the correct values based on the data shown in the confusion matrices. **
ANSWER CHOICES:
Result |
Value |
---|---|
1 |
|
0.2 |
|
1.0 |
|
3 |
|
0.4 |
|
0 |
|
0.7 |
|
5 |
SOLUTION:
Result |
Value |
---|---|
1 |
|
1.0 |
|
3 |
|
0.4 |